<?php
/**
 *  💡 免责声明：本软件不得用于商业用途，仅做学习交流
 *  ⚠️ 权利声明：本软件由版权人提供产品技术支持
 *  📅 项目编号：NX2025-0135
 */
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUserClosuresTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up()
    {
        Schema::create('user_closures', function (Blueprint $table) {
            $table->unsignedInteger('ancestor')->comment('祖先');
            $table->unsignedInteger('descendant')->comment('后代');
            $table->unsignedTinyInteger('distance')->comment('距离');
            $table->primary(['ancestor', 'descendant']);
        });
        \Illuminate\Support\Facades\DB::statement("ALTER TABLE `user_closures` comment '用户关系表'");
    }

    /**
     * Reverse the migrations.
     */
    public function down()
    {
        Schema::dropIfExists('user_closures');
    }
}
